package com.ejd.web.vo.genl;

import java.util.List;





import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.model.SelectItem;


import com.ejd.service.IShoesClassService;
import com.ejd.utils.MessageFactory;
import com.ejd.utils.SpringFacesUtil;
import com.ejd.web.bo.impl.ShoesClass;
import com.ejd.web.constant.EjdConstants;
import com.ejd.web.constant.SpringBeanConstants;

@ManagedBean(name="existShoesClass")
@SessionScoped
public class ExistShoesClassBean implements java.io.Serializable {

	private SelectItem[] shoesClassItems;

	public SelectItem[] getShoesClassItems() {
		return shoesClassItems;
	}

	public void setShoesClassItems(SelectItem[] shoesClassItems) {
		this.shoesClassItems = shoesClassItems;
	}
	public ExistShoesClassBean() {
		
		IShoesClassService<ShoesClass,Long> shoesClassService = (IShoesClassService<ShoesClass,Long>)SpringFacesUtil.getSpringBean(SpringBeanConstants.SHOES_CLASS_SERVICE_BEAN_NAME);
		shoesClassService.setEntityClass(ShoesClass.class);
		shoesClassService.setPKClass(Long.class);
		List<ShoesClass> shoesClasss = shoesClassService.getAll("serialNumber", EjdConstants.ORDER_BY_ASC_TRUE);
		SelectItem[] tempShoesClassItems = new SelectItem[shoesClasss.size()];
		if (null != shoesClasss && !(shoesClasss.isEmpty())) {
			for (int i=0; i< tempShoesClassItems.length; i++) {
				ShoesClass shoesClass = (ShoesClass) shoesClasss.get(i);
				String shoesClassNameN18 = MessageFactory.getMessage(EjdConstants.USER_BUNDLE_NAME,shoesClass.getClassName(), FacesMessage.SEVERITY_ERROR).getDetail();
				tempShoesClassItems[i] = new SelectItem(shoesClass.getClassCode(),shoesClassNameN18);
			}
		}
		this.setShoesClassItems(tempShoesClassItems);
	}
}
